export function useSearchAndTable(props: any) {
	const hyFormRef = ref();
	const tableRef = ref();
	const searchData = ref({});

	const handleSearch = () => {
		searchData.value = {
			...hyFormRef.value.hyForm,
			...props.searchDefault,
		};
	};
	const handleRest = () => {
		tableRef.value.state = {
			pageInfo: {
				current: 1,
				size: 10,
			},
			total: 0,
			loading: false,
			tableData: [],
		};
		hyFormRef.value.resetFields();
		searchData.value = JSON.parse(JSON.stringify(props.searchDefault));
	};

	const slots = computed(() => {
		const res = props.tableColumns.filter((item: any) => {
			return item.slot;
		});
		return res;
	});
	return {
		hyFormRef,
		tableRef,
		searchData,
		handleSearch,
		handleRest,
		slots,
	};
}
